//
//  TestViewController6.m
//  MSDemo
//
//  Created by ms on 2023/12/12.
//

#import "TestViewController6.h"

@interface TestViewController6 ()

{
    UIView *_view;
}

@end

@implementation TestViewController6

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"update frame";
    
    _view = ms_newView();
    [_view ms_makeChains:^(MSChainMaker * _Nonnull make) {
        
        make
        .ms_frame(100, 200, 100, 100)
        .ms_backgroundColor(UIColor.blackColor)
        .ms_lineWidth(1)
        .ms_lineColor(UIColor.blackColor)
        .ms_cornerRadii(10)
        .ms_colors(@[UIColor.yellowColor, UIColor.redColor])
        .ms_badgeText([NSString stringWithFormat:@"%d", arc4random() % 100 + 1])
        .ms_badgeTextColor(UIColor.whiteColor)
        .ms_badgeBackgroundColor(UIColor.redColor)
        .ms_addToSuperView(self.view);
    }];
    [_view.ms_label ms_makeChains:^(MSChainMaker * _Nonnull make) {
        
        make
        .ms_text(@"hello world")
        .ms_textColor(UIColor.blackColor)
        .ms_font(MS_SYSTEM_FONT_OF_SIZE(13));
    }];
    
    UIButton *btn = ms_newButton();
    [btn ms_makeChains:^(MSChainMaker * _Nonnull make) {
        
        make
        .ms_backgroundColor(UIColor.blackColor)
        .ms_title(@"更新 frame", UIControlStateNormal)
        .ms_titleColor(UIColor.whiteColor, UIControlStateNormal)
        .ms_topLeftCornerRadii(10)
        .ms_bottomRightCornerRadii(10)
        .ms_addTarget(self, @selector(updateViewFrame))
        .ms_addToSuperView(self.view);
    }];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_view.mas_bottom).offset(50);
        make.centerX.equalTo(_view);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(30);
    }];
}


#pragma mark - event
/** 点击了“更新 frame”按钮 */
- (void)updateViewFrame
{
    [_view ms_makeChains:^(MSChainMaker * _Nonnull make) {
        
        make
            .ms_frame(100, 200, arc4random() % 100 + 200, arc4random() % 100 + 100)
            .ms_badgeText([NSString stringWithFormat:@"%d", arc4random() % 100 + 1]);
//        .ms_drawCornerAndBorderLine()
//        .ms_newGradientLayer(MSGradientLayer.new.ms_colors(@[UIColor.yellowColor, UIColor.redColor]));
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
